package com.fz.service.system.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fz.common.ResponseEntity;
import com.fz.dto.system.log.LoginLogDto;
import com.fz.dto.system.log.LogDto;
import com.fz.entity.log.*;
import com.fz.mapper.log.*;
import com.fz.service.system.LogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@Service
@SuppressWarnings("unchecked")
public class LogServiceImpl implements LogService {

    @Resource
    private SysLoginLogMapper sysLoginLogMapper;
    @Resource
    private SysOperLogMapper sysOperLogMapper;
    @Resource
    private SysErrorLogMapper sysErrorLogMapper;
    @Resource
    private ClientOperLogMapper clientOperLogMapper;
    @Resource
    private ClientErrorLogMapper clientErrorLogMapper;

    /**
     * @方法描述: 分页查询system系统登录日志
     * @参数:
     * @返回值:
     * @创建人: I am God
     * @创建时间:: 2021/3/4
     */
    public ResponseEntity findSysLoginLogList(LoginLogDto loginLogDto, int pageSize, int pageNum) throws Exception{
        Page<SysLoginLog> page = new Page<>(pageNum,pageSize);
        IPage<SysLoginLog> loginLogList = sysLoginLogMapper.findSysLoginLogList(page,loginLogDto);
        return ResponseEntity.buildSuccess(loginLogList);
    }

    /**
     * @方法描述: 分页查询system系统操作日志
     * @参数:
     * @返回值:
     * @创建人: I am God
     * @创建时间:: 2021/3/4
     */
    public ResponseEntity findSysOperLogList(LogDto logDto, int pageSize, int pageNum) throws Exception{
        Page<SysOperLog> page = new Page<>(pageNum,pageSize);
        IPage<SysOperLog> operLogList = sysOperLogMapper.findSysOperLogList(page,logDto);
        return ResponseEntity.buildSuccess(operLogList);
    }

    /**
     * @方法描述: 分页查询system系统异常日志
     * @参数:
     * @返回值:
     * @创建人: I am God
     * @创建时间:: 2021/3/4
     */
    public ResponseEntity findSysErrorLogList(LogDto logDto, int pageSize, int pageNum) throws Exception{
        Page<SysErrorLog> page = new Page<>(pageNum,pageSize);
        IPage<SysErrorLog> errorLogList = sysErrorLogMapper.findSysErrorLogList(page,logDto);
        return ResponseEntity.buildSuccess(errorLogList);
    }

    /**
     * @方法描述: 分页查询client系统操作日志
     * @参数:
     * @返回值:
     * @创建人: I am God
     * @创建时间:: 2021/3/4
     */
    public ResponseEntity findClientOperLogList(LogDto logDto, int pageSize, int pageNum) throws Exception{
        Page<ClientOperLog> page = new Page<>(pageNum,pageSize);
        IPage<ClientOperLog> operLogList = clientOperLogMapper.findClientOperLogList(page,logDto);
        return ResponseEntity.buildSuccess(operLogList);
    }

    /**
     * @方法描述: 分页查询client系统异常日志
     * @参数:
     * @返回值:
     * @创建人: I am God
     * @创建时间:: 2021/3/4
     */
    public ResponseEntity findClientErrorLogList(LogDto logDto, int pageSize, int pageNum) throws Exception{
        Page<ClientErrorLog> page = new Page<>(pageNum,pageSize);
        IPage<ClientErrorLog> errorLogList = clientErrorLogMapper.findClientErrorLogList(page,logDto);
        return ResponseEntity.buildSuccess(errorLogList);
    }
}
